//
//  NewsModel.m
//  SportSocial
//
//  Created by yull on 14/12/22.
//  Copyright (c) 2014年 yull. All rights reserved.
//

#import "NewsModel.h"

@implementation NewsModel

+ (instancetype)newsWithDict:(NSDictionary *)dict
{
    NewsModel *newsModel = [[NewsModel alloc] init];
    
    for (NSString *key in dict.allKeys) {
        id value = [dict objectForKey:key];
        if ([value isKindOfClass:[NSNull class]]) {
            value = nil;
        }
        
        [newsModel setValue:value forKey:key];
    }
    return newsModel;
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    if ([key isEqualToString:@"id"]) {
        self.newsId = [value integerValue];
    }
}

+ (NSMutableArray *)newsArrayWithDictArray:(NSArray *)dictArray
{
    NSMutableArray *array = [NSMutableArray array];
    
    for (NSDictionary *dict in dictArray) {
        [array addObject:[self newsWithDict:dict]];
    }
    return array;
}
@end
